using Business.Models;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace Business.EntityFrameworkCore
{
    public static class BusinessDbContextModelCreatingExtensions
    {
        public static void ConfigureBusiness(this ModelBuilder builder)
        {
            Check.NotNull(builder, nameof(builder));

            builder.Entity<Book>(b =>
            {
                b.ToTable("Book");

                b.ConfigureByConvention();

                b.Property(x => x.Name).IsRequired();

        
            });

            builder.Entity<PrintTemplate>(b =>
            {
                b.ToTable("base_print_template");

                b.ConfigureByConvention();
                
                b.Property(x => x.Name).IsRequired();
            });

            builder.Entity<Procurement>(b =>
            {
                b.ToTable("base_procurement");

                b.ConfigureByConvention();
                
                b.Property(x => x.Externaltrackingnumber).IsRequired();
                b.Property(x => x.Operator).IsRequired();
                b.Property(x => x.Inboundordernumber).IsRequired();
                b.Property(x => x.Documentremarks).IsRequired();
                b.Property(x => x.Reservationnumber).IsRequired();
                b.Property(x => x.Trackingnumber).IsRequired();
                b.HasIndex(x => x.Carriers);

                b.HasIndex(x => x.Vendor);

                b.HasIndex(x => x.Appointmentrequesttime);

                b.HasIndex(x => x.Externaltrackingnumber);

                b.HasIndex(x => x.Inboundordernumber);

                b.HasIndex(x => x.Inboundtime);

                b.HasIndex(x => x.Reservationnumber);

                b.HasIndex(x => x.Trackingnumber);

            });

            builder.Entity<Formmian>(b =>
            {
                b.ToTable("formmian");

                b.ConfigureByConvention();
                
                b.Property(x => x.Trackingnumber).IsRequired();
                b.Property(x => x.Kkname).IsRequired();
            });

            builder.Entity<Good>(b =>
            {
                b.ToTable("base_good");

                b.ConfigureByConvention();
                
                b.Property(x => x.Auxiliarybarcode).IsRequired();
                b.Property(x => x.ItemNo).IsRequired();
                b.Property(x => x.Length).IsRequired();
                b.Property(x => x.Barcode).IsRequired();
                b.Property(x => x.Weight).IsRequired();
                b.Property(x => x.Referenceprice).IsRequired();
                b.Property(x => x.Abbreviation).IsRequired();
                b.Property(x => x.Width).IsRequired();
                b.Property(x => x.GoodNo).IsRequired();
                b.Property(x => x.GoodName).IsRequired();
                b.Property(x => x.HangTagPrice).IsRequired();
                b.Property(x => x.Remark).IsRequired();
                b.Property(x => x.Classification).IsRequired();
                b.Property(x => x.GoodType).IsRequired();
                b.Property(x => x.VolumeUnit).IsRequired();
                b.Property(x => x.LengthUnit).IsRequired();
                b.Property(x => x.Volume).IsRequired();
                b.Property(x => x.InsuredValue).IsRequired();
                b.Property(x => x.Grade).IsRequired();
                b.Property(x => x.WeightUnit).IsRequired();
                b.Property(x => x.BrandNo).IsRequired();
                b.Property(x => x.Unit).IsRequired();
                b.Property(x => x.Height).IsRequired();
            });

            builder.Entity<Purchase>(b =>
            {
                b.ToTable("purchase");

                b.ConfigureByConvention();
                
                b.Property(x => x.PurchaseUnitprice).IsRequired();
                b.Property(x => x.ProcurementTotal).IsRequired();
                b.Property(x => x.ProcurementFreight).IsRequired();
                b.Property(x => x.PurchasingStaff).IsRequired();
                b.Property(x => x.ProcurementStatus).IsRequired();
                b.Property(x => x.SpecificationModel).IsRequired();
                b.Property(x => x.QuantityPurchased).IsRequired();
                b.Property(x => x.PrepaymentAmount).IsRequired();
                b.Property(x => x.Brand).IsRequired();
                b.Property(x => x.Image).IsRequired();
                b.Property(x => x.Remark).IsRequired();
                b.Property(x => x.PurchaseOrdernumber).IsRequired();
                b.Property(x => x.AfterFoldingprice).IsRequired();
                b.Property(x => x.OtherFreight).IsRequired();
                b.Property(x => x.DateOfmanufacture).IsRequired();
                b.Property(x => x.VendorID).IsRequired();
                b.Property(x => x.GoodID).IsRequired();
                b.Property(x => x.GoodName).IsRequired();
                b.Property(x => x.DateOfpurchase).IsRequired();
                b.Property(x => x.EstimatedArrivaldate).IsRequired();
                b.Property(x => x.WarehouseId).IsRequired();
                b.Property(x => x.ExpirationDate).IsRequired();
                b.Property(x => x.DiscountedRate).IsRequired();
                b.Property(x => x.ReservoirId).IsRequired();
                b.Property(x => x.WarehouselocationId).IsRequired();
                b.Property(x => x.RegionId).IsRequired();
            });

            builder.Entity<InventoryQuantity>(b =>
            {
                b.ToTable("inventoryQuantity");

                b.ConfigureByConvention();
                
                b.Property(x => x.ProductID).IsRequired();
                b.Property(x => x.Unit).IsRequired();
                b.Property(x => x.AvailableInventory).IsRequired();
                b.Property(x => x.MaxStock).IsRequired();
                b.Property(x => x.SellingInTransit).IsRequired();
                b.Property(x => x.StorageLocationId).IsRequired();
                b.Property(x => x.TotalInTransit).IsRequired();
                b.Property(x => x.ActualInventory).IsRequired();
                b.Property(x => x.TransferringInTransit).IsRequired();
                b.Property(x => x.LastUpdated).IsRequired();
                b.Property(x => x.PurchasingInTransit).IsRequired();
                b.Property(x => x.FrozenInventory).IsRequired();
                b.Property(x => x.AreaId).IsRequired();
                b.Property(x => x.WarehouseAreaId).IsRequired();
                b.Property(x => x.ProcessingOrderInTransit).IsRequired();
                b.Property(x => x.WarehouseID).IsRequired();
                b.Property(x => x.OtherInTransit).IsRequired();
                b.Property(x => x.LockedInventory).IsRequired();
            });


            builder.Entity<SpecType>(b =>
            {
                b.ToTable("specType");

                b.ConfigureByConvention();
                
                b.Property(x => x.SpecTypeNo).IsRequired();
                b.Property(x => x.SpecTypeName).IsRequired();
            });

            builder.Entity<Spec>(b =>
            {
                b.ToTable("spec");

                b.ConfigureByConvention();
                
                b.Property(x => x.Color).IsRequired();
                b.Property(x => x.Otherspec).IsRequired();
                b.Property(x => x.Image).IsRequired();
                b.Property(x => x.SpecNo).IsRequired();
            });

            builder.Entity<Good>(b =>
            {
                b.ToTable("base_good");

                b.ConfigureByConvention();
                
                b.Property(x => x.Auxiliarybarcode).IsRequired();
                b.Property(x => x.ItemNo).IsRequired();
                b.Property(x => x.Length).IsRequired();
                b.Property(x => x.Barcode).IsRequired();
                b.Property(x => x.Weight).IsRequired();
                b.Property(x => x.Referenceprice).IsRequired();
                b.Property(x => x.Abbreviation).IsRequired();
                b.Property(x => x.Width).IsRequired();
                b.Property(x => x.GoodNo).IsRequired();
                b.Property(x => x.GoodName).IsRequired();
                b.Property(x => x.HangTagPrice).IsRequired();
                b.Property(x => x.Remark).IsRequired();
                b.Property(x => x.Classification).IsRequired();
                b.Property(x => x.GoodType).IsRequired();
                b.Property(x => x.VolumeUnit).IsRequired();
                b.Property(x => x.LengthUnit).IsRequired();
                b.Property(x => x.Volume).IsRequired();
                b.Property(x => x.InsuredValue).IsRequired();
                b.Property(x => x.Grade).IsRequired();
                b.Property(x => x.WeightUnit).IsRequired();
                b.Property(x => x.BrandNo).IsRequired();
                b.Property(x => x.Unit).IsRequired();
                b.Property(x => x.Height).IsRequired();
            });

            builder.Entity<Brand>(b =>
            {
                b.ToTable("brand");

                b.ConfigureByConvention();
                
                b.Property(x => x.BrandName).IsRequired();
                b.Property(x => x.BrandNo).IsRequired();
            });

            builder.Entity<InboundAppointments>(b =>
            {
                b.ToTable("InboundAppointments");

                b.ConfigureByConvention();
                
                b.Property(x => x.Remind).IsRequired();
                b.Property(x => x.PurchaseNumber).IsRequired();
                b.Property(x => x.HandoverStatus).IsRequired();
                b.Property(x => x.InboundStatus).IsRequired();
                b.Property(x => x.ApplicationTimeline).IsRequired();
                b.Property(x => x.DocumentNumber).IsRequired();
                b.Property(x => x.ReservoirAreaId).IsRequired();
                b.Property(x => x.RegionId).IsRequired();
                b.Property(x => x.Documenttype).IsRequired();
                b.Property(x => x.RepositoryId).IsRequired();
                b.Property(x => x.Applicant).IsRequired();
                b.Property(x => x.TrackingNumber).IsRequired();
                b.Property(x => x.Field118).IsRequired();
                b.Property(x => x.MakeAppointment).IsRequired();
                b.Property(x => x.Carriers).IsRequired();
                b.Property(x => x.ExternalNumber).IsRequired();
                b.Property(x => x.HandoverTime).IsRequired();
                b.Property(x => x.BinlocationId).IsRequired();
                b.Property(x => x.DocumentRemarks).IsRequired();
            });

            builder.Entity< InboundAppointments>(b =>
            {
                b.ToTable(" InboundAppointments");

                b.ConfigureByConvention();
                
                b.Property(x => x.HandoverStatus).IsRequired();
                b.Property(x => x.ApplicationTimeline).IsRequired();
                b.Property(x => x.PurchaseNumber).IsRequired();
                b.Property(x => x.Remind).IsRequired();
                b.Property(x => x.BinlocationId).IsRequired();
                b.Property(x => x.DocumentNumber).IsRequired();
                b.Property(x => x.InboundStatus).IsRequired();
                b.Property(x => x.ExternalNumber).IsRequired();
                b.Property(x => x.RegionId).IsRequired();
                b.Property(x => x.TrackingNumber).IsRequired();
                b.Property(x => x.ReservoirAreaId).IsRequired();
                b.Property(x => x.HandoverTime).IsRequired();
                b.Property(x => x.MakeAppointment).IsRequired();
                b.Property(x => x.Applicant).IsRequired();
                b.Property(x => x.Field118).IsRequired();
                b.Property(x => x.RepositoryId).IsRequired();
                b.Property(x => x.DocumentRemarks).IsRequired();
                b.Property(x => x.Carriers).IsRequired();
                b.Property(x => x.Documenttype).IsRequired();
            });

            //Code generation...
        }
    }
}
